﻿<navigation:Page xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="MVVM_S.Samples.HelpDesk.Home" 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
	xmlns:vm="clr-namespace:MVVM_S.Samples.HelpDesk.ViewModels"          
				 xmlns:converters="clr-namespace:MVVM_S.Samples.HelpDesk.Converters"
	mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
	Title="Home"
	Style="{StaticResource PageStyle}">
	<navigation:Page.Resources>
		<vm:OpenTicketViewModel x:Key="OpenTicketsVM"/>
		<converters:CategoryConverter x:Key="CategoryConverter" />
		<converters:UserConverter x:Key="UserConverter" />
		<converters:OfficeConverter x:Key="OfficeConverter" />
	</navigation:Page.Resources>
	<Grid x:Name="LayoutRoot"
		  DataContext="{Binding Source={StaticResource OpenTicketsVM}}">
		<ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}"
					  Margin="0"
					  IsTabStop="False"
					  Padding="0">

			<StackPanel x:Name="ContentStackPanel">

				<TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" 
								   Text="Home"/>
				<TextBlock x:Name="ContentText" Style="{StaticResource ContentTextStyle}" 
								   Text="Home page content"/>
				<sdk:DataGrid  ItemsSource="{Binding Path=OpenTickets}"
							   AutoGenerateColumns="False">
					<sdk:DataGrid.Columns>
						<sdk:DataGridTemplateColumn Header="Title" SortMemberPath="Title">
							<sdk:DataGridTemplateColumn.CellTemplate>
								<DataTemplate>
									<HyperlinkButton Content="{Binding Title}"
													 NavigateUri="{Binding TicketID, StringFormat='/Ticket/{0}'}" />
								</DataTemplate>
							</sdk:DataGridTemplateColumn.CellTemplate>
						</sdk:DataGridTemplateColumn>
						<sdk:DataGridTextColumn Header="Category" Binding="{Binding CategoryID,Converter={StaticResource CategoryConverter}}" />
						<sdk:DataGridTextColumn Header="Ticket For" Binding="{Binding UserID,Converter={StaticResource UserConverter}}" />
						<sdk:DataGridTextColumn Header="Office" Binding="{Binding OfficeID,Converter={StaticResource OfficeConverter}}" />
						<sdk:DataGridTextColumn Header="Escalation" Binding="{Binding EscalationLevel, StringFormat='Level {0}'}" />
						<sdk:DataGridTextColumn Header="Opened"
												Binding="{Binding Updated, StringFormat=g}" />
						<sdk:DataGridTextColumn Header="Last Update" Binding="{Binding Updated, StringFormat=g}" />
						<sdk:DataGridTextColumn Header="Update By" Binding="{Binding UpdatedBy,Converter={StaticResource UserConverter}}" />
					</sdk:DataGrid.Columns>
				</sdk:DataGrid>
			</StackPanel>

		</ScrollViewer>
	</Grid>

</navigation:Page>